<template>
  <div class="album-category">
    <div class="category-buttons">
      <button
          v-for="category in categories"
          :key="category.id"
          class="category-button"
          :style="{ backgroundColor: category.color }"
          @click="selectCategory(category)"
      >
        {{ category.name }}
      </button>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue';

// 模拟分类数据
const categories = ref([
  { id: 1, name: '旅行', color: '#ff6b6b' },
  { id: 2, name: '美食', color: '#4ecdc4' },
  { id: 3, name: '宠物', color: '#ffe66d' },
  { id: 4, name: '风景', color: '#48dbfb' },
  { id: 5, name: '城市', color: '#f368e0' },
  { id: 6, name: '人像', color: '#1dd1a1' },
  { id: 7, name: '建筑', color: '#ff9f43' },
  { id: 8, name: '夜景', color: '#54a0ff' },
  { id: 9, name: '自然', color: '#00d2d3' },
  { id: 10, name: '动物', color: '#5f27cd' },
]);

// 选中分类事件
const selectCategory = (category) => {
  console.log('选中分类:', category.name);
  // 这里可以触发父组件的事件或跳转到对应分类页面
};
</script>

<style scoped>
.album-category {
  max-width: 1200px;
  margin: 0 auto; /* 居中对齐 */
  padding: 20px;
}

.category-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center; /* 按钮居中对齐 */
}

.category-button {
  padding: 10px 20px;
  border: none;
  border-radius: 25px;
  color: white;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.category-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
</style>